<?php


namespace app\admin\controller;



use app\admin\service\RequestService;
use app\model\KefuUser;

class KefuUserController extends AController{

    public function index(RequestService $curdService){
        $list = $curdService->index(new KefuUser(), ['shop'])->each(function ($v){
            $v->shopTitle = getRelValue($v->shop, 'title');
        });

        return jsonSuccess([
            'items' => $list->items(),
            'total' => $list->total(),
        ]);

    }

    public function add(RequestService $curdService){
        return $curdService->add(new KefuUser());
    }

    public function edit(RequestService $curdService){
        if (request()->isPost()){
            return $curdService->edit(new KefuUser());
        }else{
            $id = request()->param('id');
            $info = KefuUser::find($id);
            return jsonSuccess([
                'info' => $info
            ]);
        }
    }

    public function del(){

    }



}
